package me.zhengjie.utils;

import javax.imageio.ImageIO;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;

public class RabbitHeadImage {
    public static void main(String[] args) {
        int width = 300;
        int height = 300;
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2d = image.createGraphics();

        // 设置背景色
        g2d.setColor(Color.WHITE);
        g2d.fillRect(0, 0, width, height);

        // 绘制兔子头的轮廓
        g2d.setColor(Color.BLACK);
        g2d.fillOval(100, 20, 200, 200); // 头部轮廓
        g2d.fillOval(300, 20, 400, 200); // 耳朵部分

        // 绘制内部细节
        g2d.setColor(Color.WHITE);
        g2d.fillOval(120, 80, 180, 200); // 脸部轮廓
        g2d.setColor(Color.BLACK);
        g2d.drawString("李", 160, 500); // 添加文字

        // 保存为JPG文件
        try {
            File outputfile = new File("D:\\360Downloads\\rabbit_head.jpg");
            ImageIO.write(image, "jpg", outputfile);
            System.out.println("Image saved successfully!");
        } catch (Exception e) {
            System.out.println("Error saving the image: " + e.getMessage());
        }
        g2d.dispose();
    }
}

